﻿using Estsh.Core.Model.EnumUtil;
using Estsh.Core.Model.Extend.IFModels;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Quartz.BaseService;
using Estsh.Core.Util;
using Estsh.Core.Wms.IRepositories;

namespace Estsh.Core.Wms.Jobs
{
    /// <summary>
    /// WMS把采购收货结果回传ERP
    /// </summary>
    public class WMSPoRecResultsJob : IJobService
    {
        private readonly IWMSInterfaceMasterRepository repository;


        public WMSPoRecResultsJob(IWMSInterfaceMasterRepository _repository)
        {
            this.repository = _repository;

        }

        public string ExecuteService(string parameter)
        {
            try
            {
                List<WmsToqc> wmsInqcs = repository.getQualityTOQCNoticeResultsInfo();
                if (wmsInqcs.Count <= 0)
                {
                    return "没有待处理的质检结果信息！";
                }

                SapInterfaceResult result = repository.InsertQualityToQcNoticeResultsInfo(wmsInqcs);
                return result.message;
            }
            catch (Exception ex)
            {
                LogHelper.Error("质检结果接口错误！" + ex);
                return "质检结果接口错误！" + ex.Message;
            }
        }
    }
}
